<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>登录 - 默笙后台管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="这不仅仅是一个后台管理系统，它基于BT4，超强的自适应，简洁，高效，大方" />
    <meta content="Mosheng" name="author" />

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <!-- App favicon -->
    <link rel="shortcut icon" href="{$Think.const.ADMIN_URL}/assets/images/favicon.ico">

    <!-- App css -->
    <link href="{$Think.const.ADMIN_URL}/css/vendor/sweetalert2.min.css" rel="stylesheet" type="text/css" />
    <link href="{$Think.const.ADMIN_URL}/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="{$Think.const.ADMIN_URL}/css/icons.min.css" rel="stylesheet" type="text/css" />
    <link href="{$Think.const.ADMIN_URL}/css/app.min.css" rel="stylesheet" type="text/css" />

</head>

<body class="authentication-bg">

    <div class="account-pages mt-5 mb-5">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-lg-5">
                    <div class="card">

                        <div class="card-body p-4">

                            <div class="text-center w-75 m-auto">
                                <a href="index.html">
                                    <span>
                                        <img src="{$Think.const.ADMIN_URL}/assets/images/logo-dark.png" alt="" height="22">
                                    </span>
                                </a>
                                <p class="text-muted mb-4 mt-3">输入您的电子邮件地址和密码访问的管理员面板。</p>
                            </div>

                            <!-- <form action="#"> -->

                            <div class="form-group mb-3">
                                <label for="emailaddress">账户</label>
                                <input class="form-control" type="text" id="emailaddress" placeholder="键入你的账户">
                            </div>

                            <div class="form-group mb-3">
                                <a href="pages-recoverpw.html" class="text-muted float-right">
                                    <small></small>
                                </a>
                                <label for="password">密码</label>
                                <input class="form-control" type="password" id="password" placeholder="键入你的密码">
                            </div>



                            <div class="form-group mb-0 text-center">
                                <button class="btn btn-primary btn-block" id="dr"> 登入 </button>
                            </div>

                            <!-- </form> -->
                        </div>
                        <!-- end card-body -->
                    </div>
                    <!-- end card -->

                    <div class="row mt-3">
                        <div class="col-12 text-center">
                            <!-- <p class="text-muted"> <a href="pages-register.html" class="text-muted ml-1">忘记密码？</a></p>
                                <p class="text-muted">还没有账号？ <a href="pages-register.html" class="text-dark ml-1"><b>注册</b></a></p> -->
                        </div>
                        <!-- end col -->
                    </div>
                    <!-- end row -->

                </div>
                <!-- end col -->
            </div>
            <!-- end row -->
        </div>
        <!-- end container -->
    </div>
    <!-- end page -->


    <!-- App js -->
    <script src="{$Think.const.ADMIN_URL}/js/vendor/sweetalert2.min.js"></script>
    <script src="{$Think.const.ADMIN_URL}/js/pages/sweet-alerts.init.js"></script>
    <script src="{$Think.const.ADMIN_URL}/js/vendor.min.js"></script>
    <script src="{$Think.const.ADMIN_URL}/js/app.min.js"></script>
    <script type="text/javascript">
        $("#dr").click(function () {
            var e = 0;
            var name = $("#emailaddress").val();
            var pwd = $("#password").val();
            if (name == "") {
                swal({
                    title: "请输入你的账户",
                    confirmButtonClass: "btn btn-confirm mt-2"
                }).
                    catch(swal.noop)
                return false;
            }

            var reg = /^[0-9a-zA-Z]+$/
            var str = name;
            if (!reg.test(str)) {
                swal({
                    title: "账户名不允许为中文",
                    confirmButtonClass: "btn btn-confirm mt-2"
                }).
                    catch(swal.noop)
                return false;
            }
            if (name.length < 6) {
                swal({
                    title: "账户名长度不够",
                    confirmButtonClass: "btn btn-confirm mt-2"
                }).
                    catch(swal.noop)
                return false;
            }
            if (pwd == "") {
                swal({
                    title: "请输入密码",
                    confirmButtonClass: "btn btn-confirm mt-2"
                }).
                    catch(swal.noop)
                return false;

            }

            if (e == 0) {
                $.post("{:U('admin.php/login/loging')}", { p: name, c: pwd }, function (data) {
                    if (data.status == '1') {
                        swal({
                            title: "登录成功",
                            text: "Good Job ！",
                            type: "success",
                            confirmButtonClass: "btn btn-confirm mt-2"
                        }).then(function() {
                           window.location.href = data.url;
                        })
                        
                    } else {
                        swal({
                            title: "账户密码错误",
                            text: "请检查输入的用户名或者密码",
                            type: "error",
                            confirmButtonClass: "btn btn-confirm mt-2"
                        })
                    }
                })
            }

        })
    </script>
</body>

</html>